<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<head lang="en">
    <th:block th:include="include :: header('添加角色')"/>
</head><body>
<form class="layui-form" style="padding: 10px" lay-filter="form">
 <div class="layui-form-item">
        <label class="layui-form-label">接口地址</label>
        <div class="layui-input-block">
            <input type="text" id="url" name="url"
                   class="layui-input" placeholder="请输入接口地址">
        </div>
    </div> <div class="layui-form-item">
        <label class="layui-form-label">接口参数</label>
        <div class="layui-input-block">
            <input type="text" id="params" name="params"
                   class="layui-input" placeholder="请输入接口参数">
        </div>
    </div> <div class="layui-form-item">
        <label class="layui-form-label">请求类型</label>
        <div class="layui-input-block">
            <input type="text" id="type" name="type"
                   class="layui-input" placeholder="请输入请求类型">
        </div>
    </div> <div class="layui-form-item">
        <label class="layui-form-label">接口名称</label>
        <div class="layui-input-block">
            <input type="text" id="name" name="name"
                   class="layui-input" placeholder="请输入接口名称">
        </div>
    </div>    <input type="hidden" id="id" name="id">
    </div>
    <div style="display: none">
        <button class="layui-btn" lay-submit lay-filter="*" id="submit">立即提交</button>
    </div>
</form>
</body>
<th:block th:include="include :: footer"/>
<script type="text/javascript">
    //从父层获取值，json是父层的全局js变量。eval是将该string类型的json串变为标准的json串
    layui.use(['form'], function () {
        var form = layui.form;
            if (parent.json) {
                var parent_json = parent.json;
                form.val("form", {
                    "id": parent_json.id
                    ,"url": parent_json.url
                    ,"params": parent_json.params
                    ,"type": parent_json.type
                    ,"name": parent_json.name
                })
            }
            form.render("select");                                // 刷性select，显示出数据
        form.on('submit(*)', function (data) {
            config.commPost("/ht/apiAdd.json", data.field, function (data, info) {
                parent.config.tableRefresh();
                parent.config.closeLayer(info);
            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

    })

    function ApplicationSave() {
        document.getElementById("submit").click();
    }
</script>
</html>

